/**
 * @class Ext.app.PurgeResultsWindow
 * @extends Ext.panel.Window
 */
Ext.define('Ext.app.PurgeResultsWindow', {
    extend: 'Ext.window.Window',
    alias: 'widget.purgeResultsWindow',

    id: 'purgeResultsWindow',
    height: 150,
    width: 400,
    layout: 'border',
    items: [
        {
            xtype: 'toolbar',
            region: 'north',
            items: [
                {
                    text: this.translations.get("ACTION.VALIDATE"),
                    handler : this.functions.get("ACTION.PURGE_RESULTS")
                },
                {
                    text: this.translations.get("ACTION.CANCEL"),
                    handler : function(button, e) {
                        var wind = button.up('purgeResultsWindow');
                        if(wind != null) {
                            wind.close();
                        }
                    }
                }
            ]
        }, 
        {
            region: 'center',
            xtype: 'panel',
            bodyPadding: 20,
            items: [
                {
                    xtype: 'datefield',
                    fieldLabel: this.translations.get("HOME.PURGE_RESULTS_SINCE"),
                    labelWidth: 150,
                    name: 'purgeResultSince',
                    format: 'd/m/Y'
                }
            ]
        }
    ],
    
    constructor: function (translations, functions) {
        this.translations = translations;
        this.functions = functions;
        
        this.callParent(arguments);
    },
    
    listeners: {
        beforeclose: function () {
            Ext.getBody().unmask();
        }
    },
    
    initComponent : function() {
        Ext.getBody().mask();
        
        this.title = this.translations.get("ACTION.PURGE_RESULTS");
        this.callParent();
    },

    getValue: function(selector) {
        var cmp = this.down(selector);
        return (cmp == null ? "" : cmp.getValue());
    },
    
    getRawValue: function(selector) {
        var cmp = this.down(selector);
        return (cmp == null ? "" : cmp.getRawValue());
    },

    getData: function() {
        return {
            "purgeResultSince": this.getRawValue("[name=purgeResultSince]")
        };
    }
});
